<template>
  <van-nav-bar :title="title" :left-arrow="leftArrow" left-text="" safe-area-inset-top @click-left="onClickLeft">
  </van-nav-bar>
</template>

<script setup>
const { goto, gotoLink } = useGoto()
const prop = defineProps({
  title: {
    type: String,
    default: '',
  },
  // 是否带返回箭头
  leftArrow: {
    type: Boolean,
    default: true,
  },
  // 直接返回的路由地址
  url: {
    type: String,
    default: '/',
  },
  urlObj: {
    type: Object,
    default: () => null,
  },
  // 是否在van-popup组件里
  inpop: {
    type: Boolean,
    default: false,
  },
})
const emits = defineEmits(['back'])
const onClickLeft = () => {
  if (prop.inpop) {
    emits('back')
  } else {
    // 先走urlObj
    goto(prop.urlObj ? prop.urlObj : prop.url)
  }
}
</script>

<style scoped lang="scss"></style>
